package com.yict.csms.resourceplan.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yict.common.entity.PageEntity;
import com.yict.common.service.impl.CommonService;
import com.yict.csms.resourceplan.dao.impl.RtgcFlTimeDaoImpl;
import com.yict.csms.resourceplan.entity.RtgcFlTime;

@Service
public class RtgcFlTimeServiceImpl extends CommonService<RtgcFlTime, Long> {

	@Autowired
	private RtgcFlTimeDaoImpl rtgcFlTimeDaoImpl;
	
	public List<RtgcFlTime> search(Map<String, Object> queryMap, PageEntity page) {
		StringBuilder queryString = new StringBuilder();
		pageEntity = new PageEntity();
		queryString.append("from RtgcFlTime as c where 1=1");
		if (queryMap != null && queryMap.size() > 0) {
			if (queryMap.get("rtgcfldate") != null
					&& !"".equals(queryMap.get("rtgcfldate"))) {
				queryString
						.append(" and c.rtgcfldate like to_date(:rtgcfldate,'yyyy-MM-dd')");
			}
			if (queryMap.get("rtgcfltime") != null
					&& !"".equals(queryMap.get("rtgcfltime"))) {
				queryString
						.append(" and c.rtgcfltime.dictid = (:rtgcfltime)");
			}
			if (queryMap.get("machine") != null
					&& !"".equals(queryMap.get("machine"))) {
				queryString
						.append(" and c.machine.dictid = (:machine)");
			}
		}
		List<RtgcFlTime> list = rtgcFlTimeDaoImpl.search(queryString.toString(),
				queryMap, page);
		pageEntity.setTotalRecord(rtgcFlTimeDaoImpl.getPageEntity().getTotalRecord());
		return list;
	}
}
